package com.inno.subject.domain.feign;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author shenzeyang
 */
@Slf4j
public class FeignRequestInterceptor implements RequestInterceptor {
    private final FeignProperties feignProperties;
    public FeignRequestInterceptor(FeignProperties feignProperties){
        this.feignProperties = feignProperties;
    }

    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.header(feignProperties.getName(), feignProperties.getValue());
        log.info("feign请求头添加成功,header:{} , value:{}",feignProperties.getName(),feignProperties.getValue());
    }
}
